#include <iostream>

using namespace std;

int main()
{
    int t;
    cin >> t;
    for (int i=1; i<=t; ++i)
    {
        int n, k;
        cin >> n >> k;
        string ans;
        for (int l=n; l>n%k; l-=k)
        {
            for (int j=1; j<=k; ++j)
            {
                ans.push_back(96+j);
            }
        }
        for (int j=1; j<=n%k; ++j)
        {
            ans.push_back(96+j);
        }
        cout << ans << endl;
    }
    return 0;
}
